package com.huawei.chenxuan;

import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.util.Map;

/**
 * @program:IntelliJ IDEA
 * @Description:将游戏结果写入文件
 * @author:Mr.CheCheHuiBujianO
 * @data: 2022/5/27 17:50
 */
@Slf4j
public class ResultFile {
    /**
     *@Description: 输入数据
     *@Param: [result]
     *@return:[ArrayList<String>]
     *@Author: Mr.Lin
     *@Date: 2022/5/27 19:31
     */
    public void addDate(Map<String,String> result){
        try(BufferedWriter bufferedWriter =
                    new BufferedWriter(new OutputStreamWriter(new FileOutputStream("result.txt",true)))){
            bufferedWriter.write(String.valueOf(result));
            bufferedWriter.newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     *@Description: 读文件内内容
     *@Param: []
     *@return:[]
     *@Author: Mr.Lin
     *@Date: 2022/5/27 19:31
     */
    public String readDate(){
        String s = null;
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/result.txt")))){
            s = bufferedReader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }


}
